package main

import (
	"fmt"
	"time"

	"github.com/mars/pkg/workpool"
)

func main() {
	workpool.InitJobQueue(10)
	dispatch := workpool.NewDispatcher(10)
	dispatch.Run()

	job := workpool.Job{Payload: workpool.PayloadFunc(task)}
	for {
		time.Sleep(time.Millisecond * 10)
		go workpool.PublishEvent(job)
	}
}

func task() error {
	time.Sleep(time.Second * 1)
	fmt.Println("excute job....")
	return nil
}
